jquery selector for elements beside one another? [migrated]

Posted by PaulHanak on Pro Webmasters See other posts from Pro Webmasters or by PaulHanak
Published on 2012-12-16T18:07:28Z Indexed on 2012/12/16 23:21 UTC
Read the original article Hit count: 127

Filed under:

this SHOULD be simple, but I have been through the Jquery Selector help for about an hour now and nothing seems to be working. Help!

I am basically trying to pull the text (an address) of a SPAN after a user clicks on the link next to it. Please note though, I will have about 10 on a page, so I cannot set a static address. It must be pulled when the user clicks.

The html code:

<a href="3" class="clicky">Click to Show Map</a> 
<span style="display: none" class="theaddy">123 Fake Street, Somewhere Else, 12341</span>

So really, my question is, how do I grab the text from .theaddy when a user clicks on .clicky?

As I said, I cannot use

 var propertyaddy = $(.theaddy).text(); 

because there are 10 of these addy's on the same page. I need some sort of "THIS" > Next To kinda thing.

I also tossed around the idea of placing the SPAN inside the A, but my efforts on that weren't working either.

Thank you in advance for any help!

© Pro Webmasters or respective owner

Related posts about jQuery